package io.printstream;

import org.junit.jupiter.api.Test;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;

/**
 * @author lianmingzhang
 * @create 2017-08-30 下午9:40
 */
public class Demo_04 {
    @Test
    public void testPringStream() throws IOException {
        OutputStream out = new FileOutputStream("src/io/printstream/a.txt");
        int firstPrintableCharacter = 33;
        int numberOfPrintableCharacters = 94;
        int numberOfCharactersPerline = 72;

        int start = firstPrintableCharacter;
        for(int j = 0; j < 8; j++) {
            for(int i = start; i < start + numberOfCharactersPerline; i++) {
                out.write(((i - firstPrintableCharacter) % numberOfPrintableCharacters) + firstPrintableCharacter);
            }

            out.write('\r');
            out.write('\n');

            start = ((start + 1) - firstPrintableCharacter) % numberOfPrintableCharacters + firstPrintableCharacter;
        }

        PrintStream printStream = new PrintStream(out,false);
        printStream.println();

    }

}
